package com.ajie.controller;


import com.ajie.entity.SysMenu;
import com.ajie.service.SysMenuService;
import com.ajie.utils.QueryInfo;
import com.ajie.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单数据控制层
 */
@RestController
@Api(tags = "菜单数据")
@RequestMapping("/menu")
@Slf4j
public class SysMenuController {

    @Autowired
    private SysMenuService menuService;


    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryInfo queryInfo){
        log.info("该文件名是：SysMenuController,该方法是：findPage");
        return menuService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加菜单")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysMenu menu){
        log.info("该文件名是：SysMenuController,该方法是：insert");
        return menuService.insert(menu);
    }

    @ApiOperation(value = "删除菜单")
    @DeleteMapping("/delete/{id}")
    public Result delete( @PathVariable("id") Long id){
        log.info("该文件名是：SysMenuController,该方法是：delete");
        return menuService.delete(id);
    }

    @ApiOperation(value = "修改菜单")
    @PutMapping("/update")
    public Result update(@RequestBody SysMenu menu){
        log.info("该文件名是：SysMenuController,该方法是：update");
        return menuService.update(menu);
    }

    @ApiOperation(value = "查询父级菜单")
    @GetMapping("/findParent")
    public Result findParent(){
        log.info("该文件名是：SysMenuController,该方法是：findParent");
        return menuService.findParent();
    }

}
